﻿using System.Reflection;
using Castle.Windsor;
using SharePointEditor.BusinessDefinitions.Interfaces;
using SPE.Core.Extensions;
using SPContextWorker;

namespace SPE.Core.Factories
{
    public class ContainerFactory
    {
        private static IWindsorContainer _container;
        //private static readonly object SyncObject = new object();
        public static IWindsorContainer GetCurrent()
        {
            if (_container == null)
            {
                //lock (SyncObject)
                //{
                    _container = new WindsorContainer();
                    _container.RegisterControllers(Assembly.GetExecutingAssembly());
                    _container.AddComponent("dataservice", typeof(ISPDataService), typeof(Gateway));
                //}
            }
            return _container;
        }
    }
}
